<template>
  <view
    :id="guide_option.guide_0.id"
    :data-guide-text="guide_option.guide_0.dataGuideText"
  >
    <view class="guide_follow" @click="handleToSubscribeQrcode">
      <view class="guide_follow_image">
        <image
          show-menu-by-longpress
          class="official_image"
          mode="widthFix"
          :src="accountImg"
        />
      </view>
    </view>
  </view>
</template>

<script>
import { guide_option } from "@/pages/home/const/mask-guide";
import { isSubscribe } from "@/service/api/sp-common";
import { mapState } from "@dcloudio/vue-cli-plugin-uni/packages/vuex3/dist/vuex.common";

export default {
  name: `official-account`,
  props: {},
  data() {
    return {
      isShow: false,
      guide_option,
      accountImg:
        "",
    };
  },
  computed: {
    platform() {
      const { platform } = uni.$u;
      return platform;
    },
    baseUrl() {
      return (
        process.env.VUE_APP_BASE_FileUrl ||
        "https://hyyxboss.oss-cn-shenzhen.aliyuncs.com/"
      );
    },
    ...mapState("sp-common/auth", ["token"]),
  },
  created() {
    // if (this.token) {
    //   this.innit();
    // }
  },
  methods: {
    innit() {
      uni.login({
        provider: "weixin", //使用微信登录
        success: async (loginRes) => {
          if (loginRes.errMsg === "login:ok") {
            const res = await isSubscribe({
              code: loginRes.code,
              appId: process.env.VUE_APP_WX_APP_ID,
            });
            this.isShow = !res;
          }
        },
      });
    },
    handleToSubscribeQrcode() {
      this.$Router.replace({
        name: "subscribeQrcode",
      });
    },
  },
};
</script>

<style scoped lang="scss">
.guide_follow {
  .official_image {
    width: 100%;
    height: 40rpx;
  }
}
</style>
